/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.hsos.samcomm.userManagement.entity;

import de.hsos.samcomm.forumManagement.entity.Forum;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import java.io.Serializable;

/**
 * Entitaet eines Benutzers.
 *
 * @author Dennis
 */
@Entity(name="members")
public class Member implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String OID;

    private String nickname;
    private String password;
    private String email;

    @ManyToMany
    private List<Forum> subscriptions = new ArrayList<>();

    /**
     * Default Konstruktor.
     */
    public Member() {}

    /**
     * Ueberladener Konstruktor.
     *
     * @param nickname
     * @param email
     * @param password
     */
    public Member(String nickname, String email, String password) {
        this.nickname = nickname;
        this.email = email;
        this.password = password;
    }

    /**
     * Get-Methode fuer die ObjektID.
     *
     * @return the OID
     */
    public String getOID() {
        return this.OID;
    }

    /**
     * Set-Mehtode fuer die ObjektID.
     *
     * @param OID the OID to set
     */
    public void setOID(String OID) {
        this.OID = OID;
    }

    /**
     * Get-Methode fuer den Nickname.
     *
     * @return nickname
     */
    public String getNickname() {
        return nickname;
    }

    /**
     * Set-Methode fuer den Nickname.
     *
     * @param nickname
     */
    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    /**
     * Get-Methode fuer das Passwort.
     *
     * @return password
     */
    public String getPassword() {
        return password;
    }

    /**
     * Set-Methode fuer das Passwort.
     *
     * @param password
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * Get-Methode fuer die E-Mail.
     *
     * @return email
     */
    public String getEmail() {
        return email;
    }

    /**
     * Set-Methode fuer die E-Mail.
     *
     * @param email
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * Get-Methode fuer die abonnierten Foren.
     *
     * @return subscriptions
     */
    public List<Forum> getSubscriptions() {
        return (List<Forum>)(List<?>)subscriptions;
    }

    /**
     * Set-Methode fuer die abonnierten Foren.
     *
     * @param subscriptions
     */
    public void setSubscriptions(List<Forum> subscriptions) {
        this.subscriptions = (List<Forum>)(List<?>)subscriptions;
    }

    /**
     * Fuegt den abonnierten Foren das uebergebene Forum ein.
     *
     * @param f
     */
    public void addSubscription(Forum f) {
        this.subscriptions.add(f);
    }

    /**
     * Ueberschriebene toString-Methode. Gibt den Namen des Benutzers zurueck.
     *
     * @return nickname
     */
    @Override
    public String toString() {
        return nickname;
    }
}
